<template>
    <div class="main-container">
        <ad-left v-if='$store.state.isPc'></ad-left>
        <div class="main">
            <ul class="ad-tab-comp" style="margin-bottom : 15px;">
                <li @click='typeChange(1)' :class='formData.record_type == 1 ? `active` : ``'>我信任的</li>
                <li @click='typeChange(2)' :class='formData.record_type == 2 ? `active` : ``'>信任我的</li>
                <li @click='typeChange(3)' :class='formData.record_type == 3 ? `active` : ``'>我屏蔽的</li>
            </ul>
            <el-table 
				:data='table'
                :header-cell-style="{background : '#E5F2FF'}"
				style='width : 1200px; margin: 0 auto;'>
                <!-- <el-table-column type='selection' width='50'></el-table-column> -->
				<el-table-column label='交易夥伴' prop='nickname'>
                    <template slot-scope="scope">
                        <div class="f-s">
                            <img :src="scope.row.avatar" alt="" class="avatar">
                            <span>{{scope.row.nickname}}</span>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label='交易次數' prop='trade_times'></el-table-column>
				<el-table-column label='信任人數' prop='trust_number'></el-table-column>
				<el-table-column label='好評率' prop='praise_rate' ></el-table-column>
			</el-table>
            <div class="center" style="padding : 15px;" v-if='table && table.length'>
                <el-pagination
                    @current-change='pageChange'
                    :page-size ='formData.limit'
                    :total='total'
                    background
                    layout="prev, pager, next">
                </el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
    import AdLeft from '@c/AdLeft'
    import {GetTrustList} from '@/api/user'
    export default {
        components: {
            AdLeft
        },
        data() {
            return {
                
                formData :{
                    record_type : '1',
                    page : 1,
                    limit : 10
                },
                table : null,
            };
        },
        mounted () {
            this.getData();
        },
        methods :{
            getData () {
                GetTrustList(this.formData).then(res => {
                    this.table = res.result.data;
                    this.total = res.result.count;
                })
            },
            pageChange (page) {
                this.formData.page = page;
                this.getData()
            },
            typeChange (type) {
                this.formData.record_type = type;
                this.page = 1;
                this.getData();
            }
        }
    }
</script>
<style lang="less" scoped>
    @import url('../../assets/css/_b.less');
    //小屏
    @media screen and (max-width : 670px) {
        .main-container{
            background: #fff;
        }
        .type-select{
            li {
                cursor: pointer;
                padding: 15px 10px;
                font-size: 14px;
            }
            .active {
                color: @mainColor;
            }
        }
    }
    //大屏
    @media screen and (min-width : 670px) {
        .main-container {
            min-width: 1200px;
            margin: 25px auto;
            display: flex;
            justify-content: center;
        }
        .main {
            width: 1140px;
            background: #fff;
            .type-select-container {
                padding: 5px 20px 5px 0;
            }
            .type-select{
                li {
                    cursor: pointer;
                    padding: 15px 50px;
                    font-size: 14px;
                }
                .active {
                    color: @mainColor;
                }
            }
        }
        .avatar {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            margin-right: 15px;
        }
    }
</style>